﻿using MediatR;
using Microsoft.EntityFrameworkCore;
using ProductIntory.Domains;
using ProductIntory.ErrorCodes;
using ProductIntory.Infrastructures.Interface;
using ProductIntory.Read.Apis.Application.Command.CheckProductWorkCommands;

namespace ProductIntory.Read.Apis.Application.CommandHandler.CheckProductWorkCommandHandlers
{
    public class ShowCheckProductWorkCommandHandler : IRequestHandler<ShowCheckProductWorkCommand, ApiResult<List<CheckProductWork>>>
    {
        IBaseRepository<CheckProductWork> CheckProductWork;

        public ShowCheckProductWorkCommandHandler(IBaseRepository<CheckProductWork> CheckProductWork)
        {
            this.CheckProductWork = CheckProductWork;
        }

        public async Task<ApiResult<List<CheckProductWork>>> Handle(ShowCheckProductWorkCommand request, CancellationToken cancellationToken)
        {
               var list =await CheckProductWork.GetAll().ToListAsync();
            return new  ApiResult<List<CheckProductWork>>
            {
                Code = ApiEnum.success,
                Message = "操作成功",
                Data = list
            };
        }
    }
}
